Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-parse-markup

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-parse-markup

Parse Svelte markup without parsing the script or style tags

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.5K
decreased by-53.51%
Maintainers
1
Weekly downloads
 
Created
Source

svelte-parse-markup

Parse Svelte markup without parsing the script or style tags.

Usage

import { parse } from 'svelte-parse-markup'

const ast = parse('some svelte code')

console.log(ast.instance.content.body)
// output:
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'instance script content',
//     content: 'instance script content'
//   }
// ]

console.log(ast.module.content.body)
// output:
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'module script content',
//     content: 'module script content'
//   }
// ]

console.log(ast.css.content.styles)
console.log(ast.css.children)
// output:
// 'css content'
// [
//   {
//     type: 'Text',
//     start: <num>,
//     end: <num>,
//     raw: 'css content',
//     content: 'css content'
//   }
// ]

svelte-parse-markup skips parsing scripts and styles, and injects a Text node instead. Check out the Svelte REPL AST output tab to compare how the original AST would look like.

Sponsors

Sponsors

License

MIT

Keywords

FAQs

Package last updated on 04 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc